// 引入路由组件

// 路由懒加载

// import Home from '@/views/Home'
// import Search from '@/views/Search'
import Login from '@/views/Login'
import Register from '@/views/Register'
import Detaol from '@/views/Detail'
import AddCartSuccess from '@/views/AddCartSuccess'
import ShopCart from '@/views/ShopCart'
import Trade from '@/views/Trade/Trade'
import Pay from '@/views/Trade/Pay'
import PaySuccess from '@/views/Trade/PaySuccess'
import Center from '@/views/Trade/Center'
// 映入二级路由
import myOrder from '@/views/Trade/Center/myOrder'
import groupOrder from '@/views/Trade/Center/groupOrder'
export default [
  {
    path: "/home/",
    // 路由懒加载
    component: () => import('@/views/Home'),
    meta: { show: true },
  },
  {
    path: "/search/:keyword?",
    // 路由懒加载
    component: () => import('@/views/Search'),
    meta: { show: true },
    name: "search"
  },
  {
    path: "/login",
    component: Login,
    meta: { show: false },
  },
  {
    path: "/register",
    component: Register,
    meta: { show: false },
  },
  {
    path: "/detaol/:skuid",   //:skuid  占位路由跳转时传参
    component: Detaol,
    meta: { show: true },
  },
  {
    path: "/addcartsuccess",
    name: "addcartsuccess",
    component: AddCartSuccess,
    meta: { show: true }
  },
  {
    path: "/shopcart",
    component: ShopCart,
    meta: { show: true }

  },
  {
    path: "/trade",
    component: Trade,
    meta: { show: true },
    // 路由独享的守卫
    // beforeEnter: (to, from, next) => {
    //   if (from.path == "/shopcart") {
    //     next()
    //   }
    // }
  },
  {
    path: "/pay",
    component: Pay,
    name: 'Pay',
    meta: { show: true }
  },
  {
    path: "/paysuccess",
    component: PaySuccess,
    name: 'PaySuccess',
    meta: { show: true }
  },
  {
    path: "/center",
    component: Center,
    name: 'Center',
    meta: { show: true },
    // 二级路由
    children: [
      {
        path: 'grouporder',
        component: groupOrder,
      },
      {
        path: 'myorder',
        component: myOrder,
      },
      {
        path: "/center",
        redirect: "/center/myorder"
      }
    ]
  },
  // 重定向，在项目跑起来的时候，访问/  立马让他定向到指定路由页面
  {
    path: "*",
    redirect: "/home"
  }
]